package com.haoze.nurse.schedule;

import com.haoze.nurse.CloudNurseApplication;
import com.haoze.nurse.dao.PatChaperonageMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@ConditionalOnProperty(prefix = "scheduledtask", name = "open", havingValue = "true")
public class NcovLabChangeSchedule {
    private final Logger logger = LoggerFactory.getLogger(NcovLabChangeSchedule.class);
    @Resource
    PatChaperonageMapper patChaperonageMapper;

    @Scheduled(cron = "0 */1 * * * ?")
//    @Scheduled(fixedDelay = 5 * 1000, initialDelay = 0)
    public void ncovLabChangeSchedule() {
        // 查询七日内申请且待审核或审核状态且检验状态为待出结果
        long t1 = System.currentTimeMillis();
        patChaperonageMapper.updateNcovReport();
        long t2 = System.currentTimeMillis();
        logger.info("更新陪护申请的NCOV检验状态耗时：{} ms", t2-t1);
    }

}
